<?php

$i=0;
foreach($dataProvider['data'] as $one){
    $content='';

    foreach($one->items as $item){

        $_link='';
        $_link=CHtml::link(
            '<i class="icon-trash"></i>',
            $this->createUrl('/cate/delete/', array('id'=>$item->cid, 'returnUrl'=>CHtml::encode($this->createUrl('/user/article', array('cid'=>$item->pid))))),
            array('rel'=>'tooltip', 'class'=>'delete', 'data-original-title'=>'Delete')
        );
//        $_link=CHtml::ajaxLink(
//            '<i class="icon-trash"></i>',
//            $this->createUrl('/cate/delete/', array('id'=>$item->cid)),
//            array(
//                'dataType' =>'json',
//                'data'=>array('returnUrl'=>$this->createUrl('/user/article', array('cid'=>$item->pid))),
//                'type'=>'POST'
//            ),
//            array('rel'=>'tooltip', 'class'=>'delete', 'data-original-title'=>'Delete')
//        );

        $content .= '<span class="items">[#'.$item->cid.']'.$item->name.'</span>'.$_link;
    }

    $_tm = new Cate();
    $_tm->pid = $one->cid;
    $content .= $this->renderPartial('cate_form', array('model'=>$_tm), true);
    if($dataProvider['cid']==0){
        $_menu[$i] = array('label'=>'[#'.$one->cid.']'.$one->name.'('.count($one->items).')','content'=>$content,'active'=> $i == 0 ? true : false);
    }else{
        $_menu[$i] = array('label'=>'[#'.$one->cid.']'.$one->name.'('.count($one->items).')','content'=>$content,'active'=> ($i+1) == $dataProvider['cid'] ? true : false);
    }


    $content='';
    $i++;
}

$this->widget('bootstrap.widgets.TbTabs', array(
    'type'=>'tabs',
    'placement'=>'left', // 'above', 'right', 'below' or 'left'
    'tabs'=>$_menu,
));

